package cate.game.play.skill.passive.god;

import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;
import cate.game.play.skill.passive.hero.英雄觉醒PH;

/**
 * 回合开始前40%降低敌方随机1个单位25%觉醒值
 */
public class 摧毁PH extends PassiveHandler {

	private int 概率;

	private int 人数;

	private int 降低值;

	//概率=4000&人数=1&降低值=25
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		人数 = args.getInt("人数", 0);
		降低值 = args.getInt("降低值", 0);
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		if (skill.owner.isDead()) {
			return;
		}
		if (!XT.chance(概率)) {
			return;
		}
		for (Fighter fighter : XT.randomPick(action.getTeamVs().getEnemyTeam(skill.owner.team).getFightersAlive(), 人数, true)) {
			fighter.skill.addAwakenEnergy(action, -降低值);
		}
	}
}
